﻿using System.Configuration;
using Books.Services;
using BooksTests.Mock;
using RefLib.IOC;
using Microsoft.Practices.Unity;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BooksTests
{
    [TestClass]
    public abstract class TestBase
    {
        [TestInitialize()]
        public void Initialize()
        {
            IUnityContainer container = SingletonContainer.Get();
            container.AddNewExtension<ServicesConfigExtension>();
            container.AddNewExtension<MockServicesConfigExtension>();
        }

        [TestCleanup()]
        public void Cleanup()
        {
            SingletonContainer.Release();
        }

        protected string ServicesMethod
        {
            get
            {
                if (_servicesMethod == null)
                    _servicesMethod = ConfigurationManager.AppSettings["ServicesMethod"];
                return _servicesMethod;
            }
        }

        private string _servicesMethod;
    }
}
